package com.fyzk.activity.zhifu;

import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.fyzk.activity.app.ActivityTaskManager;
import com.fyzk.activity.app.App;
import com.fyzk.activity.app.AppToast;
import com.fyzk.activity.lottery.basketball.prizeoptimization.JZPrizeOptimizationActivity;
import com.fyzk.activity.lottery.jc.football.JCInfo;
import com.fyzk.activity.lottery.jc.football.adapter.JCZQZhiFuBaseAdapter;
import com.fyzk.activity.lottery.jc.football.guoguan.JC_GuoGuanDialog;
import com.fyzk.activity.lottery.recommend_order.RecommendTypePopupwindow;
import com.fyzk.activity.lottery.zc.tz_dialog.ZCBF_infor;
import com.fyzk.activity.myview.BeiShuEditText.ET_action;
import com.fyzk.activity.user.LoginActivity;
import com.fyzk.data.AppLotteryInfos;
import com.fyzk.data.preference.MySharedPreferences;
import com.fyzk.interfaces.OnFootballPayTeamDeleteListener;
import com.fyzk.net.Constants;
import com.fyzk.net.PublicMethod;
import com.fyzk.utils.IntentParamUtils;
import com.fyzk.utils.LogUtil;
import com.fyzk.utils.LogUtils;
import com.fyzk.utils.LotteryIDUtils;
import com.fyzk.utils.jc.JZGroupUtil;
import com.fyzk.utils.jc.JZPrizeComputeUtil;
import com.fyzk.view.ASView;
import com.fyzk.view.ViewCallBack;
import com.tyjc.lottery.R;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import http.DataUtil.text.TextUtil;

/***
 * 竞彩足球支付的类
 *
 * @author miao
 */
public abstract class SportsFootballPayActivity extends JCBasePayActivity implements ET_action,
        OnFootballPayTeamDeleteListener, ASView.OnValueChangedLisener {

    public TextView buyType;
    private TextView ziXuan;
    private EditText mEtMemo;

    protected ListView listView;
    private ASView touBei;
    private View shadow_unclick;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if(!App.isBaskOrder){
            findViewById(R.id.zhifu_top_po).setVisibility(View.VISIBLE);
            findViewById(R.id.zhifu_top_po).setOnClickListener(this);
            findViewById(R.id.zhifu_top_hemai).setVisibility(View.VISIBLE);
            findViewById(R.id.zhifu_top_hemai).setOnClickListener(this);
            findViewById(R.id.footballPayUI_etMemo).setVisibility(View.GONE);
        }
        initGuoGuanView();
        setDefaultGGAndZhushu();
    }

    @Override
    public boolean isJC() {
        return true;
    }

    @Override
    protected void onResume() {
        super.onResume();
        String ggfs = tv_guoGuanStyle.getText().toString();
        JC_GuoGuanDialog.result = ggfs;
    }

    @Override
    public View initCenterView() {
        View view = LayoutInflater.from(this).inflate(R.layout.jz_zhifu, null);
        // 优惠券
        LinearLayout coupon_ll = view.findViewById(R.id.zhifu_coupon_ll);
        coupon_ll.addView(couponZhifuView);

        mEtMemo = view.findViewById(R.id.footballPayUI_etMemo);
        buyType = view.findViewById(R.id.jc_zhifu_type);
        ziXuan = view.findViewById(R.id.jc_zhifu_center_addmore);
        shadow_unclick = view.findViewById(R.id.shadow_unclick);
        shadow_unclick.setOnClickListener(this);
        tv_guoGuanStyle = view.findViewById(R.id.jc_zhifu_ggfs);
        listView = view.findViewById(R.id.jc_zhifu_listview);
        initAdapter();
        listView.addFooterView(getListFooterView());
        touBei = view.findViewById(R.id.jc_zhifu_et_toubei);
        touBei.setLeftText("投");
        touBei.setValue(1);
        touBei.setRightText("倍");
        touBei.setOnValueChangedLisener(this);
        ziXuan.setOnClickListener(new OnClick());
        tv_guoGuanStyle.setOnClickListener(new OnClick());

        // 晒单方式
        final TextView recommendType_tv = view.findViewById(R.id.jc_zhifu_recommendtype_tv);
        // 分割线
        if (App.isBaskOrder) {
            recommendType_tv.setVisibility(View.VISIBLE);
        }

        final String[] rr_type = {"公开推荐", "不发起推荐", "保密推荐"};
        if (recommendTypePopupwindow == null) {
            recommendTypePopupwindow = new RecommendTypePopupwindow(getContext(), rr_type);
            recommendTypePopupwindow.setListener(new RecommendTypePopupwindow
                    .RecommendTypeItemListener() {
                @Override
                public void onItem(int position) {
                    recommendType = position;
                    recommendType_tv.setText(rr_type[position]);
                    if (recommendType == 1) {
                        btm_sure.setText("支付");
                    } else {
                        btm_sure.setText("购彩\n并晒单");
                    }
                }
            });
        }
        recommendType_tv.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(SportsFootballPayActivity.this, ShaiDanActivity.class);
                intent.putExtra("amount", getAmount());
                intent.putExtra("recommendType",recommendType);
                intent.putExtra("proportions",proportions);
                intent.putExtra("proportionType",proportionType);
                intent.putExtra("isShowAmt",isShowAmt);
                intent.putExtra("isShowMaxSP",isShowMaxSP);
                startActivityForResult(intent, IntentParamUtils.JC_GENDAN);
            }
        });
        return view;
    }


    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.zhifu_top_po:
                if (!MySharedPreferences.getInstance().getLoginStatus()) {
                    AppLotteryInfos.clear();
                    ViewCallBack.getInstance().countDownObjs.clear();
                    ActivityTaskManager.getInstance().closeAllActivity();
                    Intent intent = new Intent(getContext(), LoginActivity.class);
                    startActivity(intent);
                }else{
                    if(JC_GuoGuanDialog.isDuoChuan){
                        showToast("奖金优化不支持多串");
                        return;
                    }

                    boolean isDanTuo = false;
                    for (JCInfo info : infos) {
                        if (info.isDan()) {
                            isDanTuo = true;
                            break;
                        }
                    }
                    String ggfs = tv_guoGuanStyle.getText().toString();

                    if (isDanTuo) {
                        showToast("奖金优化不支持胆拖");
                    } else if (ggfs.contains("串")||ggfs.equals("单关")) {
                        if (getZhushu() <= Constants.MAX_PO_ZHU) {
                            Intent intent = new Intent(this, JZPrizeOptimizationActivity.class);
                            intent.putExtra("chuanguan", ggfs);
                            intent.putExtra("zhushu", getZhushu() * getBeishu());
                            intent.putExtra("minprize", prizeMinStr);
                            intent.putExtra(IntentParamUtils.LOTTERYID, lotteryId);
                            startActivityForResult(intent, IntentParamUtils.TO_PO);
                        } else {
                            showToast("注数大于" + Constants.MAX_PO_ZHU + "注时无法进行奖金优化");
                        }
                    } else {
                        showToast(R.string.guoguan_hint);
                    }
                }
                break;
        }
    }


    private RecommendTypePopupwindow recommendTypePopupwindow;


    private String typeStrs[] = null;

    @Override
    protected void adapterChange() {
        adapter.setInfors(infos, isDanguan);
    }

    @Override
    public void setBtmView() {
        super.setBtmView();
        if (infos != null && infos.size() > 0) {

            JZPrizeComputeUtil util = new JZPrizeComputeUtil(this, infos, lotteryId);
            Log.e("dsadasd",getZhushu()+"---");
            if (getZhushu() > 0) {
                shadow_unclick.setVisibility(View.VISIBLE);
                PrizeAsyncTask prizeAsyncTask = new PrizeAsyncTask();
                prizeAsyncTask.execute(util);
            } else {
                btm_leftMoney.setText("至少选择一注");
            }
        } else {
            LogUtil.d("先选择一场比赛");
        }
    }

    String prizeMinStr;
    String prizeMaxStr;

    class PrizeAsyncTask extends AsyncTask<JZPrizeComputeUtil, String, String> {

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            btm_leftMoney.setText("正在计算预计奖金....");
        }

        @Override
        protected String doInBackground(JZPrizeComputeUtil... util) {
            LogUtil.v("开始计算了，计算中修改就被发现了");
            double prizeMax = 0.0;
            double prizeMin = 0.0;
            if (isDanguan) {//单关
                prizeMin = util[0].getDanPrize(false);
                prizeMax = util[0].getDanPrize(true);
            } else {//过关
                if(JC_GuoGuanDialog.isDuoChuan){
                    typeStrs = JC_GuoGuanDialog.duo_result.split("\\,");
                    int teamNum = JC_GuoGuanDialog.team_num;
                    if (null != typeStrs) {
                        // 存放最小预计彩金
                        List<Double> prizeMinData = new ArrayList<>();

                        LogUtils.e("====infos===="+infos.size());

                        List<ArrayList<JCInfo>> groupInfoDataMax = getGroupInfoData(infos, teamNum, false);
                        List<ArrayList<JCInfo>> groupInfoDataMin = getGroupInfoData(infos, teamNum, true);

                        for(int j=0;j<groupInfoDataMax.size();j++){
                            ArrayList<JCInfo> childInfoData = groupInfoDataMax.get(j);
                            for (int i = 0; i < typeStrs.length; i++) {
                                if (typeStrs[i].contains("串")) {
                                    prizeMax += util[0].getDoublePrize2(typeStrs[i], childInfoData, true);
                                }
                            }
                        }

                        for (int j = 0; j < groupInfoDataMin.size(); j++) {
                            ArrayList<JCInfo> childInfoData = groupInfoDataMin.get(j);
                            for (int i = 0; i < typeStrs.length; i++) {
                                if (typeStrs[i].contains("串")) {
                                    double tempMinPrize = util[0].getDoublePrize2(typeStrs[i], childInfoData, false);
                                    prizeMinData.add(tempMinPrize);
                                }
                            }
                        }

                        // 获取集合中最小的预计彩金
                        for (int i=0;i<prizeMinData.size();i++){
                            double prize = prizeMinData.get(i);
                            if(Collections.min(prizeMinData) == prize){
                                prizeMin += prize;
                            }
                        }
                    }
                }else{
                    typeStrs = JC_GuoGuanDialog.result.split("\\,");
                    if (null != typeStrs) {
                        for (int i = 0; i < typeStrs.length; i++) {
                            if (typeStrs[i].contains("串")) {
                                prizeMax += util[0].getDoublePrize(typeStrs[i], true);
                                if (prizeMin == 0) {
                                    prizeMin = util[0].getDoublePrize(typeStrs[i], false);
                                }
                            }
                        }
                    }
                }
            }
            minPrize = prizeMin * getBeishu();
            double maxPrize = prizeMax * getBeishu();
            maxBounusPrize = maxPrize;
            if (minPrize > maxPrize){
                minPrize = maxPrize;
            }
            prizeMinStr = PublicMethod.formatMoney(minPrize * 100);
            prizeMaxStr = PublicMethod.formatMoney(maxPrize * 100);
            StringBuffer prizeB = new StringBuffer();
            if (prizeMinStr.equals(prizeMaxStr)) {
                prizeB.append(prizeMinStr);
                expectedPrize = prizeMinStr;
            } else {
                prizeB.append(prizeMinStr);
                prizeB.append("~");
                prizeB.append(prizeMaxStr);
                expectedPrize = prizeMinStr + "~" + prizeMaxStr;
            }
            return prizeB.toString();
        }

        @Override
        protected void onPostExecute(String o) {
            super.onPostExecute(o);
            shadow_unclick.setVisibility(View.GONE);
            LogUtil.v("计算完了，展示计算结果");
            String infoStr = "预计奖金：<font color='#fd4a4a'>" + o + "</font>米";
            btm_leftMoney.setText(Html.fromHtml(infoStr));
        }
    }

    // 用于临时存放K场次M串，排列组合方式信息
    public List<ArrayList<JCInfo>> tempGroupData;
    private List<ArrayList<JCInfo>> getGroupInfoData(ArrayList<JCInfo> infos, int teamNum, boolean isMin) {
        List<ArrayList<JCInfo>> groupInfoData;
        switch (lotteryId) {
            //胜平负过关投注方式
            case LotteryIDUtils.JZSPFRSPF_LOTTERY_ID_INT:
                if(isMin){
                    groupInfoData = getSPFGroupInfoData(infos, teamNum, isMin);
                }else{
                    ArrayList<JCInfo> spfInfos = JZGroupUtil.clone(infos);
                    JZGroupUtil.initSPFInfos(spfInfos);
                    groupInfoData = getSPFGroupInfoData(spfInfos, teamNum, isMin);
                }
                break;
            //混合过关投注方式
            case LotteryIDUtils.JZHH_LOTTERY_ID_INT:
                if(isMin){
                    groupInfoData = getHGGroupInfoData(infos, teamNum, isMin);
                }else{
                    ArrayList<JCInfo> hgInfos = JZGroupUtil.clone(infos);
                    JZGroupUtil.initHGInfos(hgInfos);
                    groupInfoData = getHGGroupInfoData(hgInfos, teamNum, isMin);
                }
                break;
            //其他过关投注方式（半全场、比分、总进球）
            default:
                groupInfoData = getOtherGroupInfoData(infos, teamNum);
                break;
        }
        return groupInfoData;
    }

    /**
     * 胜平负投注数据分组处理
     * @param infos
     * @param teamNum
     * @param isMin
     * @return
     */
    private List<ArrayList<JCInfo>> getSPFGroupInfoData(ArrayList<JCInfo> infos, int teamNum, boolean isMin) {
        List<ArrayList<JCInfo>> groupInfoData = new ArrayList<>();
        // 保存设置为胆的比赛场次信息
        ArrayList<JCInfo> danInfoData = new ArrayList<>();
        // 保存不是胆的比赛场次信息
        ArrayList<JCInfo> noDanInfoData = new ArrayList<>();

        // 例如选择8场比赛，8串n过关方式
        if(infos.size() == teamNum){
            if(isMin){
                groupInfoData.add(infos);
            }else{
                groupInfoData = JZGroupUtil.convert(infos, teamNum);
            }
            LogUtils.e("====groupInfoData===="+groupInfoData.toString());
        }else{
            for (int i = 0; i < infos.size(); i++) {
                JCInfo tempInfo = infos.get(i);
                int checkNum = tempInfo.getOnclikNum();
                if (checkNum > 0) {
                    if(tempInfo.isDan()){
                        // 找出设为胆的比赛场次
                        danInfoData.add(tempInfo);
                    }else{
                        // 找出不是胆的场次
                        noDanInfoData.add(tempInfo);
                    }
                }
            }
            getGroupSort(noDanInfoData, teamNum - danInfoData.size());

            LogUtils.e("====tempGroupData===="+tempGroupData.toString());

            for(int i=0;i<tempGroupData.size();i++){
                ArrayList<JCInfo> tempInfoData = tempGroupData.get(i);
                // 将作为胆的比赛场次信息添加到每一个排列信息中
                tempInfoData.addAll(danInfoData);
                if (isMin) {
                    groupInfoData.add(tempInfoData);
                } else {
                    List<ArrayList<JCInfo>> groupInfoData1 = JZGroupUtil.convert(tempInfoData, teamNum);
                    groupInfoData.addAll(groupInfoData1);
                }
            }
        }
        return groupInfoData;
    }

    /**
     * 混合过关投注数据分组处理
     * @param infos
     * @param teamNum
     * @param isMin
     * @return
     */
    private List<ArrayList<JCInfo>> getHGGroupInfoData(ArrayList<JCInfo> infos, int teamNum, boolean isMin) {
        List<ArrayList<JCInfo>> groupInfoData = new ArrayList<>();
        // 保存设置为胆的比赛场次信息
        ArrayList<JCInfo> danInfoData = new ArrayList<>();
        // 保存不是胆的比赛场次信息
        ArrayList<JCInfo> noDanInfoData = new ArrayList<>();
        // 例如选择8场比赛，8串n过关方式
        if(infos.size() == teamNum){
            if(isMin){
                groupInfoData.add(infos);
            }else{
                groupInfoData = JZGroupUtil.convert(infos, teamNum);
            }
        }else{
            for (int i = 0; i < infos.size(); i++) {
                JCInfo tempInfo = infos.get(i);
                int checkNum = tempInfo.getOnclikNum();
                if (checkNum > 0) {
                    if(tempInfo.isDan()){
                        // 找出设为胆的比赛场次
                        danInfoData.add(tempInfo);
                    }else{
                        // 找出不是胆的场次
                        noDanInfoData.add(tempInfo);
                    }
                }
            }
            getGroupSort(noDanInfoData, teamNum - danInfoData.size());

            LogUtils.e("====tempGroupData===="+tempGroupData.toString());

            for(int i=0;i<tempGroupData.size();i++){
                ArrayList<JCInfo> tempInfoData = tempGroupData.get(i);
                // 将作为胆的比赛场次信息添加到每一个排列信息中
                tempInfoData.addAll(danInfoData);
                if (isMin) {
                    groupInfoData.add(tempInfoData);
                } else {
                    List<ArrayList<JCInfo>> groupInfoData1 = JZGroupUtil.convert(tempInfoData, teamNum);
                    groupInfoData.addAll(groupInfoData1);
                }
            }
        }
        return groupInfoData;
    }

    private List<ArrayList<JCInfo>> getOtherGroupInfoData(ArrayList<JCInfo> infos, int teamNum) {
        List<ArrayList<JCInfo>> groupInfoData = new ArrayList<>();
        // 保存设置为胆的比赛场次信息
        ArrayList<JCInfo> danInfoData = new ArrayList<>();
        // 保存不是胆的比赛场次信息
        ArrayList<JCInfo> noDanInfoData = new ArrayList<>();
        // 例如选择8场比赛，8串n过关方式
        if(infos.size() == teamNum){
            groupInfoData.add(infos);
        }else{
            for (int i = 0; i < infos.size(); i++) {
                JCInfo tempInfo = infos.get(i);
                int checkNum = tempInfo.getOnclikNum();
                if (checkNum > 0) {
                    if(tempInfo.isDan()){
                        // 找出设为胆的比赛场次
                        danInfoData.add(tempInfo);
                    }else{
                        // 找出不是胆的比赛场次
                        noDanInfoData.add(tempInfo);
                    }
                }
            }
            getGroupSort(noDanInfoData, teamNum - danInfoData.size());

            LogUtils.e("====tempGroupData===="+tempGroupData.toString());

            for(int i=0;i<tempGroupData.size();i++){
                ArrayList<JCInfo> tempInfoData = tempGroupData.get(i);
                // 将作为胆的比赛场次信息添加到每一个排列信息中
                tempInfoData.addAll(danInfoData);
                groupInfoData.add(tempInfoData);
            }
        }
        return groupInfoData;
    }

    /**
     * K场次M串排列组合方式
     * 例如 通常请款下（不加胆时）：选择8场比赛，3串n过关方式，
     *     8场中任选3场有56种情况
     * @param info      选择的场次信息
     * @param teamNum  M串 M的数量
     */
    public void getGroupSort(ArrayList<JCInfo> info, int teamNum) {
        tempGroupData = new ArrayList<>();
        if (info == null || info.size() == 0) {
            return;
        }
        ArrayList<JCInfo> list = new ArrayList();
        combine(info, 0, teamNum, list);
    }

    // 从字符数组中第begin个字符开始挑选number个字符加入list中
    public void combine(ArrayList<JCInfo> info, int begin, int number, ArrayList<JCInfo> list) {
        if (number == 0) {
            // 将每一种排列组合结果保存在tempGroupData中
            tempGroupData.add(new ArrayList<JCInfo>(list));
            return;
        }
        if (begin == info.size()) {
            return;
        }
        list.add(info.get(begin));
        combine(info, begin + 1, number - 1, list);
        list.remove(info.get(begin));
        combine(info, begin + 1, number, list);
    }

    @Override
    public int getBeishu() {
        return touBei.getValue();
    }

    @Override
    public String getMemo() {
        String memo = mEtMemo.getText().toString();
        if (TextUtil.isEmpty(memo))
            return super.getMemo();
        return memo;
    }

    protected abstract int getMaxGuoGuan();

    @Override
    protected String getContent() {
        return getContent(infos, isDanguan);
    }

    public String getContent(List<JCInfo> infos, boolean isDanguan) {
        return "";
    }

    @Override
    public String getPeriod() {
        return "";
    }

    @Override
    protected void clear() {
        JC_GuoGuanDialog.result = JC_GuoGuanDialog.GG_RESULT;
        tv_guoGuanStyle.setText(JC_GuoGuanDialog.GG_RESULT);
//        initGuoGuanView();
        clearData();
    }

    private void clearData() {
        for (int i = 0; i < infos.size(); i++) {
            JCInfo info = infos.get(i);
            if (info.getOnclikNum() > 0) {
                info.setOnclikNum(0);
                info.setHg_more(0);
                info.setDan(false);
                Iterator<String> keys = info.btnHGPojo.keySet().iterator();
                while (keys.hasNext()) {
                    info.btnHGPojo.get(keys.next()).isSel = false;
                }

            }
            List<ZCBF_infor> touZhu = info.getTouZhuInfor();
            for (int j = 0; j < touZhu.size(); j++) {
                touZhu.get(j).setSelect(false);
            }
            info.setResult("");
        }
    }

    @Override
    public void initGuoGuanView() {
        super.initGuoGuanView();
        if (isDanguan) {
            tv_guoGuanStyle.setText("单关");
        } else {
            tv_guoGuanStyle.setText(JC_GuoGuanDialog.result);
        }

    }

    @Override
    public void onValueChanged(ASView view, int value) {
        beishu = value;
        if (beishu < 1) {
            beishu = 1;
        }
        setBtmView();
    }

    class OnClick implements OnClickListener {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.jc_zhifu_center_addmore:
                    addMoreTeam();
                    break;
                case R.id.jc_zhifu_ggfs:
                    int changCi = 0;
                    for (JCInfo info : infos) {
                        if (info.getOnclikNum() > 0) {
                            changCi++;
                        }
                    }
                    if ((!isDanguan && changCi < 2) || (isDanguan && changCi < 1)) {
                        AppToast.getToast().show("请添加更多场比赛");
                        break;
                    }
                    if (!isDanguan) {
                        String cg = tv_guoGuanStyle.getText().toString();
                        if (cg.contains("串")) {
                            JC_GuoGuanDialog.result = cg;
                        }
                        Intent intent = new Intent(SportsFootballPayActivity.this,
                                JC_GuoGuanDialog.class);
                        intent.putExtra(IntentParamUtils.JC_CHANGCI, changCi);
                        intent.putExtra(IntentParamUtils.JC_MAXGUOGUAN, getMaxGuoGuan());
                        intent.putExtra(IntentParamUtils.LOTTERYID, lotteryId);
                        startActivityForResult(intent, IntentParamUtils.CHANGE_GUOGUAN);
                    }
                    break;
                case R.id.shadow_unclick:
                    showToast("正在计算奖金，不能修改比赛哦");
                    break;
                default:
                    break;
            }
        }
    }

    private void setDefaultGGAndZhushu() {
        int changci = infos.size();
        if (changci > getMaxGuoGuan()) {
            changci = getMaxGuoGuan();
        }
        JC_GuoGuanDialog.isDuoChuan = false;
        JC_GuoGuanDialog.result = changci + "串" + 1;
        tv_guoGuanStyle.setText(JC_GuoGuanDialog.result);
        adapter.jiSuanZhuShu();
        ((JCZQZhiFuBaseAdapter) adapter).refreshDan();
        setBtmView();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case IntentParamUtils.CHANGE_GUOGUAN:
                tv_guoGuanStyle.setText(JC_GuoGuanDialog.result);
                if (resultCode == IntentParamUtils.OK) {
                    adapter.jiSuanZhuShu();
                    adapter.refreshDan();
                    setBtmView();
                }
                break;
            case 0x6:
                isDanguan = data.getBooleanExtra(IntentParamUtils.TYPE_GUOGUAN, false);
                initGuoGuanView();
                adapterChange();
                break;
            case IntentParamUtils.SEND_TOGETHERBUY:
                if (resultCode == IntentParamUtils.CANCLE) {
                    setBtmView();
                } else {
                    clear();
                    finish();
                }
                break;
            case IntentParamUtils.TO_PO:
                if (resultCode == 0x6) {
                    finish();
                }
                break;
            case IntentParamUtils.JC_GENDAN:
                if (resultCode == IntentParamUtils.OK) {
                    recommendType = data.getIntExtra("recommendType", -1);
                    if (recommendType == 1) {
                        btm_sure.setText("支付");
                    } else {
                        btm_sure.setText("购彩\n并晒单");
                    }
                }
                break;
        }
    }

    /**
     * 初始化比赛对阵列表的Adapter
     */
    protected abstract void initAdapter();

    private void addMoreTeam() {
        setResult(IntentParamUtils.JC_ADDMORE);
        finish();
    }

    @Override
    public void action() {
        setBtmView();
    }

    @Override
    public int getOneAmount() {
        return 2;
    }

    @Override
    public void finish() {
        super.finish();
    }

    @Override
    public void onDelete(JCInfo jcInfo) {
        Iterator<String> iterators = jcInfo.btnHGPojo.keySet().iterator();
        while (iterators.hasNext()) {
            jcInfo.btnHGPojo.get(iterators.next()).isSel = false;
        }
        List<ZCBF_infor> zcbf_infors = jcInfo.getTouZhuInfor();
        for (ZCBF_infor zcbf_infor : zcbf_infors) {
            zcbf_infor.setSelect(false);
        }
        jcInfo.setDan(false);
        jcInfo.setDaneble(false);
        jcInfo.setOnclikNum(0);
        jcInfo.setHg_more(0);
        JC_GuoGuanDialog.result = JC_GuoGuanDialog.GG_RESULT;
        initGuoGuanView();
    }


}
